package com.itheima.simpledateformate;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class SimpleDateFormatDemo {
    public static void main(String[] args) throws ParseException {
        Date now = new Date();
        // 创建一个日期对象，转换为字符串
        SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
        String result1 = sdf1.format(now);
        System.out.println(result1);
        // 创建一个日期字符串，转换为日期对象
        String dateStr = "2048-01-01";
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date date1 = sdf.parse(dateStr);
        System.out.println(date1);
    }
}
